module libeventd.http.Struct;

import
	libeventd.Types;
	
enum{
	EVHTTP_REQ_OWN_CONNECTION	=0x0001,
	EVHTTP_PROXY_REQUEST		=0x0002,
	EVHTTP_USER_OWNED		=0x0004,
	EVHTTP_REQ_DEFER_FREE		=0x0008,
	EVHTTP_REQ_NEEDS_FREE		=0x0010,
}

enum evhttp_cmd_type {
	EVHTTP_REQ_GET,
	EVHTTP_REQ_POST,
	EVHTTP_REQ_HEAD,
	EVHTTP_REQ_PUT,
	EVHTTP_REQ_DELETE
}

enum evhttp_request_kind {
	EVHTTP_REQUEST,
	EVHTTP_RESPONSE 
}


extern(C):

struct evhttp_uri {
	char *scheme; /* scheme; e.g http, ftp etc */
	char *userinfo; /* userinfo (typically username:pass), or NULL */
	char *host; /* hostname, IP address, or NULL */
	int port; /* port, or zero */
	char *path; /* path, or "". */
	char *query; /* query, or NULL */
	char *fragment; /* fragment or NULL */
}

struct evhttp_request {
	TAILQ_ENTRY!(evhttp_request) next;
	evhttp_connection*	evcon;
	int				flags;
	evkeyvalq*			input_headers;
	evkeyvalq*			output_headers;

	char*			remote_host;
	ev_uint16_t		remote_port;
	char*			host_cache;
	evhttp_request_kind	kind;
	evhttp_cmd_type		type;

	size_t		headers_size;
	size_t		body_size;

	char*		uri;
	evhttp_uri*	uri_elems;
	char			major;
	char			minor;	
	ev_int		response_code;		/* HTTP Response code */
	char*		response_code_line;	/* Readable response */

	evbuffer*		input_buffer;	/* read data */
	ev_int64_t		ntoread;
	
	ubyte[4]		__data;
	/*
	short 		__chunked;  // :1,			a chunked request 
	short 		__userdone; // :1;			the user has sent all data 
	*/
	
	evbuffer*		output_buffer;	/* outgoing post or data */

	/* Callback */
	void function(evhttp_request *, void *)	cb;
	void*			cb_arg;

	void function(evhttp_request*,void*)		chunk_cb;
}

